-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Prettier log output #221
base: main
Are you sure you want to change the base?
Conversation
Thanks very much for this PR! |
Could this become a alternative log macro rather than the default one? |
I think it's OK, but no idea about a proper naming. |
@@ -20,29 +20,47 @@ namespace Pilot | |||
fatal | |||
}; | |||
|
|||
static constexpr const char* FileName(const char* path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 该方法相比于 C++ 更适合 C,
C 使用C++ 可以考虑使用strrchr()
,std::string_view
. - 这种判断方法不适用于处理 Windows 的路径, 比如在 MSVC 中宏
__FILE__
的值.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 这里其实用到了c++14 起的一个特性,constexpr 函数的编译期计算,可以看这里 https://godbolt.org/z/jjYqfjz7s , O1级别以上的优化都会在编译期算出表达式,也就是执行期不会call function
- 没有理解
- 确实,只做了简单的测试,用
std::filesystem::path::preferred_separator
替代即可
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
没注意到 constexpr, 抱歉. strrchr()
确实不支持, 不过 std::string_view
需要使用到的成员函数应该支持.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static constexpr std::string_view FileName(std::string_view path)
{
return path.substr(path.find_last_of(std::filesystem::path::preferred_separator) + 1);
}
仅供参考.
Maybe make log pattern configurable |
feat:
|
feat:Prettier log output with log src file and line, looks like:
test pr